#include <bits/stdc++.h>
using namespace std;
const int N = 66;
int n, len, cnt;
int a[N];
bool v[N];
bool dfs(int stick, int cab, int last)
{
	if (stick > cnt)
		return true;
	if (cab == len)
		return dfs(stick + 1, 0, 1);
	int fail = 0;
	for (int i = last; i <= n; i++)
	{
		if (!v[i] && cab + a[i] <= len && fail != a[i])
		{
			v[i] = true;
			if (dfs(stick, cab + a[i], i + 1))
				return true;
			fail = a[i];
			v[i] = false;
			if (cab == 0 || cab + a[i] == len)
				return false;
		}
	}
	return false;
}
bool cmp(int a, int b)
{
	return a > b;
}
inline void solve()
{
	int val = 0, sum = 0;
	int kkk=0;
	for (int i = 1; i <= n; i++)
	{
		int tmp;
		cin >> tmp;
		if (tmp <= 50)
		{
			a[++kkk] = tmp;
			val = max(a[kkk], val);
			sum += a[kkk];
		}
	}
	sort(a + 1, a + n + 1, cmp);
	for (len = val; len <= sum; len++)
	{
		if (sum % len)
			continue;
		cnt = sum / len;
		if (dfs(1, 0, 1))
		{
			cout << len << endl;
			break;
		}
	}
}
int main()
{
	cin >> n;
	solve();
	return 0;
}